#include "../common/udp.h"

class Communicate:public UDP
{
public:
	Communicate(const int port, const char *transitIp, const int transitPort, const char *peerMacAddr, const char *ownMacAddr);
	~Communicate();

public:
	void loginTransit();
	void getPeerNetAddr();
	void penetrate();
	void sendNormal();

private:
	virtual int dealPackage(const unsigned char *package, const int packageSize, const struct sockaddr_in *rNetAddr);

	int clientLoginRep(const unsigned char *data, const int dataSize, const struct sockaddr_in *rNetAddr);
	int clientGetPeerNetAddrRep(const unsigned char *data, const int dataSize, const struct sockaddr_in *rNetAddr);
	int sendNormalRep(const unsigned char *data, const int dataSize, const struct sockaddr_in *rNetAddr);

	char _macAddr[CPU_ID_SIZE + 1];
	char _peerMacAddr[CPU_ID_SIZE + 1];
	struct sockaddr_in _peerNetAddr;
	struct sockaddr_in _transitNetAddr;
};

